<template>
	<div id="reception">
		<v-content class="width-1200">

			<div class="info" v-if="tableData.length>0">
				<div>
					<div class="title"><span>{{tableData[0].articleTitle}}</span></div>
					<div class="time my-flex-between">
						<span></span>
						<span>{{tableData[0].createTime | formNewsDate}}</span>
					</div>
					<div class="img">
						<img class="bgback" :src="tableData[0].articleCoverUrl" alt="" />
						<template v-if="tableData[0].sourceUrl">
							<img class="playicon" @click.stop="playStart($event,0,tableData[0])" src="../../assets/news/icon_home_suspend@2x.png" />
							<video v-show="isPlay" preload="auto" controls="" loop="loop" class="video" style="width: 100%;height: 100%;" :src="tableData[0].sourceUrl"></video>
						</template>
					</div>
					<div class="content" v-html="tableData[0].articleContent"> </div>
				</div>
			</div>
			<!--往期视频-->
			<div class="title"><span>往期视频</span></div>
			<div class="one-card hover" @click="changeRouter('/newsDetail?id='+item.id+'&type=2')" v-if="index>0" v-for="(item,index) in tableData">
				<div class="left">
					<span class="title">{{item.articleTitle}}</span>
					<div class="content two-row">
						<span>{{item.articleContent}}</span>
					</div>
					<span class="time">{{item.createTime | formNewsDate}}</span>
				</div>
				<div class="right" :style="{backgroundImage:'url('+item.articleCoverUrl+')'}"></div>
			</div>
		</v-content>
	</div>
</template>

<script>
	import service from '@/js/services/news';
	export default {
		name: 'reception',
		data() {
			return {
				type: 2,
				url: 'http://pic.58pic.com/58pic/15/68/59/71X58PICNjx_1024.jpg',
				params: {
					pageNum: 1,
					pageSize: 10
				},
				total: 1,
				tableData: [],
				isPlay:false
			}
		},
		mounted() {
			this.getNewsList();
		},
		methods: {
			...service,
			changeRouter(url) {
				this.$router.push(url);
			},
			playStart(ev, index, item) {
				let self = this;
				var target = ev.target;
				var dom = this.tool.getTargetDom($(ev.target), 'img');
				var video = $('.video')[0];
				var bgimg = dom.find('.bgback')[0];
				var playicon = ev.target;
				if(video.paused) {
					this.isPlay = true;
					video.play();
					bgimg.style.visibility = 'hidden';
					playicon.style.display = "none";
				} else {
					video.pause();
					this.isPlay = false
					bgimg.style.visibility = "visible";
					playicon.style.display = "block";

				}
			}
		}
	}
</script>

<style lang="less">
	@import '../../less/base/base.less';
	#reception {
		.title {
			/*margin-top: 10px;*/
			height: 40px;
			line-height: 40px;
		}
		.one-card {
			margin-top: 10px;
			border-radius: 6px;
			&:nth-of-type(1) {
				margin-top: 0;
			}
			height: 120px;
			background-color: #fff;
			padding: 9px 18px;
			display: flex;
			.left {
				flex: 1;
				font-size: 14px;
				.title {
					font-size: 18px;
					color: @color-txt1;
				}
				.content {
					color: @color-txt2;
					height: 38px;
					margin-top: 14px;
					line-height: 150%;
					overflow: hidden;
				}
				.time {
					font-size: 14px;
					color: @color-txt3;
					display: block;
					margin-top: 17px;
				}
			}
			.right {
				height: 102px;
				flex: 160px 0;
				background-position: center;
			}
		}
		.info {
			/*margin-top: 16px;*/
			background-color: #fff;
			padding-top: 40px;
			padding-bottom: 40px;
			>div {
				width: 680px;
				margin: 0 auto;
			}
			.title {
				font-size: 18px;
				text-align: center;
			}
			.time {
				margin-top: 28px;
				font-size: 14px;
				color: @color-txt3;
			}
			.img {
				margin-top: 14px;
				position: relative;
				img {
					width: 100%;
				}
				.video {
					position: absolute;
					left: 0;
					top: 0;
					width: 100%;
					height: 100%;
				}
				.playicon {
					width: 50px;
					position: absolute;
					left: 50%;
					top: 50%;
					transform: translate(-50%, -50%);
				}
			}
			.content {
				margin-top: 39px;
			}
		}
	}
</style>